<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<html>
<head>
    <title>学生修改密码</title>
    <script src="${pageContext.request.contextPath}/bootstrap/js/jQuery.js"></script>
    <script type="text/javascript">
        function checkForm() {
            var oldPassword = $("#oldPassword").val();
            var newPassword1 = $("#newPassword1").val();
            var newPassword2 = $("#newPassword2").val();
            //原密码验证：非空和正确性验证
            if (oldPassword == null || oldPassword == "") {
                alert("请输入原密码！");
                return false;
            }
            if (oldPassword != '${currentUser.password}') {
                alert("原密码错误，请重新输入！");
                return false;
            }
            //新密码验证：非空和2次输入一致性验证
            if (newPassword1 == null || newPassword1 == "") {
                alert("请输入新密码！");
                return false;
            }
            if (newPassword2 == null || newPassword2 == "") {
                alert("请输入确认新密码！");
                return false;
            }
            if (newPassword1 != newPassword2) {
                alert("确认新密码填写错误，请重新输入！");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="data_list">
    <div class="data_info">
        <p>&nbsp;修改个人密码</p>
    </div>
    <div class="data_content">
        <form action="${pageContext.request.contextPath}/studentAction!updatePassword" method="post" onsubmit="return checkForm()">
            <input type="hidden" value="${currentUser.id }" name="student.id">
            <table width="40%" align="center">
                <tr>
                    <td><label>用户名：</label></td>
                    <td><input type="text" value="${currentUser.name }" name="student.name" readonly="readonly"/></td>
                </tr>
                <tr>
                    <td><label>原密码：</label></td>
                    <td><input type="password" id="oldPassword"/></td>
                </tr>
                <tr>
                    <td><label>新密码：</label></td>
                    <td><input type="password" id="newPassword1" name="student.password"/></td>
                </tr>
                <tr>
                    <td><label>确认新密码：</label></td>
                    <td><input type="password" id="newPassword2"/></td>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2" style="align-content: center">
                        <button class="btn btn-primary" type="submit">确定修改</button>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>
</html>
